/*
 * @Author: szx
 * @Date: 2022-04-22 13:22:07
 * @LastEditTime: 2022-04-22 13:34:24
 * @Description:
 * @FilePath: \leetcode\剑指offerII\092\092.js
 */
/**
 * @param {string} s
 * @return {number}
 */
var minFlipsMonoIncr = function (s) {
    const n = s.length;
    // 0变1，1变0
    const dp = new Array(n + 1).fill(0).map(() => new Array(2).fill(0));
    for (let i = 0; i < n; i++) {
        dp[i][0];
        if (s[i] == 0) {
            dp[i + 1][1] = dp[i][1] + 1;
        } else if (s[i] == 1) {
            dp[i + 1][0] = dp[i][0] + 1;
        }
    }
    return Math.min(dp[n][0], dp[n][1]);
};
